//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "fn_spectatingChangeTarget.sqf"
#include <btc_macros.h>
TRACE_1("Start",_this);

private ["_sel","_name","_x","_found"];
_sel = lbCurSel 120;
_found = false;
_name = "";
if (_sel >= 0) then {
	_name = lbText [120,_sel];
	switch (true) do
	{
		case (BTC_spectating == 1) : {{if (name _x == _name) exitWith {BTC_r_s_target = _x; _found = true;};} foreach units group player;};
		case (BTC_spectating == 2) : {{if (side _x == BTC_side && name _x == _name) exitWith {BTC_r_s_target = _x; _found = true;};} foreach (if (isMultiplayer) then { playableUnits } else { switchableUnits });};//switchableunits
		case (BTC_spectating == 3) : {{if (name _x == _name) exitWith {BTC_r_s_target = _x; _found = true;};} foreach (if (isMultiplayer) then { playableUnits } else { switchableUnits });};
	};
};
TRACE_1("End",BTC_r_s_target);